<?php
/**
 * 
 *
 * @category   Application_Extensions
 * @package    Paint
 * @copyright  Copyright 2006-2010 Idragonsolution Developments
 * @license    http://idragonsolution.com/
 * @version    $Id: Bootstrap.php 9747 2012-07-26 02:08:08Z Thien $
 * @author     Thien
 */
?>

<?php
  $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/scripts/composer_paint.js');
   $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/paint.js');
    $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/picker.js');
    $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/pen.js');
    $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/eraser.js');
     $this->headScript()
      ->appendFile($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/upload.js');
  $this->headLink()
          ->prependStylesheet($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/css/main.css');
  $this->headLink()
          ->prependStylesheet($this->layout()->staticBaseUrl . 'application/modules/Paint/externals/paint/css/picker.css');
      
      
  $allowed = 1;
  $user = Engine_Api::_()->user()->getViewer();
  $allowed_upload = (bool) Engine_Api::_()->authorization()->getAdapter('levels')->getAllowed('paint', $user, 'upload');
  if($allowed_upload) $allowed = 1;
?>



<script type="text/javascript">
    var paint = new Paint();
    var composePaint =  null;
     function isCanvasSupported(){
      var elem = document.createElement('canvas');
      return !!(elem.getContext && elem.getContext('2d'));
    }
    
  en4.core.runonce.add(function() {
    
    composePaint = new Composer.Plugin.Paint({
      title : '<?php echo $this->translate('Add Scribl') ?>',
      lang : {
        'Add Scribl' : '<?php echo $this->string()->escapeJavascript($this->translate('Add Scribl')) ?>',
        'Select File' : '<?php echo $this->string()->escapeJavascript($this->translate('Select File')) ?>',
        'cancel' : '<?php echo $this->string()->escapeJavascript($this->translate('cancel')) ?>',
        'Attach' : '<?php echo $this->string()->escapeJavascript($this->translate('Attach')) ?>',
        'Loading...' : '<?php echo $this->string()->escapeJavascript($this->translate('Loading...')) ?>',
        'Choose Source': '<?php echo $this->string()->escapeJavascript($this->translate('Choose Source')) ?>',
      },
      allowed : <?php echo $allowed;?>,
      type : type,
      requestOptions : {
        'url' : en4.core.baseUrl + 'recorder/index/compose-upload/format/json/c_type/'+type,
        'subUrl': 'recorders/upload'
      }
    });
        
    var type = 'wall';
    if (composeInstance.options.type) type = composeInstance.options.type;
    composeInstance.addPlugin(composePaint );
    paint.composePaint = composePaint;
  });
  
  
   
</script>
